﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RayDen.SceneLab.Controllers
{
    public class ApplicationController
    {
        protected List<IDisposable> dElements;


        protected long MemoryOnStart;

        public ApplicationController()
        {
            dElements = new List<IDisposable>();
            MemoryOnStart = GC.GetTotalMemory(false);
        }


        public string UsedMemory
        {
            get
            {
                return string.Format("{0}", GC.GetTotalMemory(false) - MemoryOnStart);
            }
        }

        public void Trace(string text, params object[] pars)
        {
            System.Diagnostics.Trace.WriteLine(string.Format("{0} {1}", DateTime.Now,string.Format(text, pars)));
        }

        public void Quit()
        {
            foreach (var disposable in dElements)
            {
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }

            Application.Exit();
        }
    }
}
